package cn.spring.cloud.activity.mybatisps.springbootrabbitmq.utils;

import cn.spring.cloud.activity.mybatisps.springbootrabbitmq.service.impl.MailService;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Author 嘉宾
 * @Data 2022/3/23 15:30
 * @Version 1.0
 * @DESC：队列A，处理发送邮件 消费者
 */
@Component
public class RabbitMQReciveA{

    @Autowired
    private MailService mailService;

    @RabbitListener(bindings =
    @QueueBinding(
            value = @Queue, //临时队列
            exchange = @Exchange(name = "mailExchange",type = "topic"), //指定交换机名称与类型
            key = {"user.*"}
    )
    )
    private void sendEMail(String uemail){
        String subject = "用户信息注册成功！";
        String content = "恭喜你注册成功！";
        mailService.sendSimpleMail(uemail, subject, content);
        //发送邮件
        System.out.println("已发送邮件");
    }

}